<!-- 商品列表 -->
<div class="table-responsive">
    <table class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>商品名称</th>
                <th>图片</th>
                <th>价格</th>
                <th>库存</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @forelse($products as $product)
            <tr>
                <td>{{ $product->id }}</td>
                <td>{{ $product->name }}</td>
                <td>
                    @if($product->main_image || !empty($product->images))
                        <i class="fas fa-images text-success" title="有商品图片"></i>
                    @else
                        <i class="fas fa-image text-muted" title="无商品图片"></i>
                    @endif
                </td>
                <td>¥{{ number_format($product->price, 2) }}</td>
                <td>{{ $product->stock }}</td>
                <td>
                    @if($product->status == 1)
                        <span class="badge bg-success">上架</span>
                    @else
                        <span class="badge bg-danger">下架</span>
                    @endif
                </td>
                <td>{{ $product->created_at->format('Y-m-d H:i') }}</td>
                <td>
                    <a href="{{ route('products.edit', $product->id) }}" class="btn btn-sm btn-primary">
                        <i class="fas fa-edit"></i> 编辑
                    </a>
                    <form action="{{ route('products.destroy', $product->id) }}" method="POST" class="d-inline">
                        @csrf
                        @method('DELETE')
                        <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除这个商品吗？')">
                            <i class="fas fa-trash"></i> 删除
                        </button>
                    </form>
                </td>
            </tr>
            @empty
            <tr>
                <td colspan="8" class="text-center">暂无商品数据</td>
            </tr>
            @endforelse
        </tbody>
    </table>
</div>

<!-- 分页 -->
<div class="mt-4">
    {{ $products->links() }}
</div>